package com.spring.controller;

import com.spring.annotation.MyServlet;
import com.spring.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@MyServlet
public class RoleController {

    @RequestMapping(value = "/role", method = "GET")
    public void index(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("role.jsp").forward(request, response);
    }

    @RequestMapping(value = "/role/delete", method = "GET")
    public void delete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        request.setAttribute("msg", "删除了一个角色, id是" + id);
        request.getRequestDispatcher("/role.jsp").forward(request, response);
    }

    @RequestMapping(value = "/role/d", method = "GET")
    public void deletePost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.sendRedirect(request.getContextPath() + "/role");
    }
}